'''
# -*- coding:utf-8 -*-
# @Project: DevOps_api
# @Date: 2023/3/27 - 22:18
# @Author: ysg
# @Describe: 

log_db.py
'''
import datetime
from libs.alarmspy.dl_mysql import get_dl_mysql
from django.core.cache import cache

conn, cursor = get_dl_mysql()

def handle_log(tag_name, log_info):
    user_id = cache.get('username_id') if cache.get('username_id') else 1
    cursor.execute(
        f'insert into ops_log_audit(tag_name, log_info, user_id) values("{tag_name}", "{log_info}", "{user_id}")')
    conn.commit()
